package org.jeecg.modules.kuner.contentbase.controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.aspect.annotation.AutoLog;
import org.jeecg.common.system.base.controller.JeecgController;
import org.jeecg.common.system.query.QueryGenerator;
import org.jeecg.modules.kuner.contentbase.entity.KrContentBase;
import org.jeecg.modules.kuner.contentbase.service.IKrContentBaseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Arrays;
import java.util.List;

/**
 * @Description: 内容管理
 * @Author: jeecg-boot
 * @Date: 2025-02-19
 * @Version: V1.0
 */
@Api(tags = "内容管理")
@RestController
@RequestMapping("/api/krContentBase")
@Slf4j
public class KrContentBaseApiController extends JeecgController<KrContentBase, IKrContentBaseService> {
    @Autowired
    private IKrContentBaseService krContentBaseService;


    @ApiOperation("根据名称获取文章信息")
    @GetMapping("/getByName/{title}")
    public Result<KrContentBase> getByName(@PathVariable String title) {
        return Result.OK("查询成功！", krContentBaseService.getOne(new LambdaQueryWrapper<KrContentBase>().eq(KrContentBase::getTitle, title).orderByDesc(KrContentBase::getCreateTime).last("limit 1")));
    }



}
